package org.aurora.model.entity;

import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Date;

public class MainSchedulerLockInfo implements Serializable {
    public MainSchedulerLockInfo() {
    }


    public MainSchedulerLockInfo(String curMainSchedulerIp, int curMainSchedulerPort, Date curMainSchedulerStartTime) {
        this.curMainSchedulerIp = curMainSchedulerIp;
        this.curMainSchedulerPort = curMainSchedulerPort;
        this.curMainSchedulerStartTime = curMainSchedulerStartTime;
    }

    /**
     * 上一个调度器 ip
     */
    private String preMainSchedulerIp;
    /**
     * 上一个主调度器端口号
     */
    private int preMainSchedulerPort;
    /**
     * 上一个主调度器地址
     */
    private String preMainSchedulerAddr;

    /**
     * 上一个主调度器
     */
    private Date preMainSchedulerStartTime;

    /**
     * 当前想要竞争的调度器地址
     */
    private String curMainSchedulerAddr;
    /**
     * 上一个调度器 ip
     */
    private String curMainSchedulerIp;
    /**
     * 上一个主调度器端口号
     */
    private int curMainSchedulerPort;
    /**
     * 当前想要竞争的调度器的竞争时间
     */
    private Date curMainSchedulerStartTime;

    public String getPreMainSchedulerAddr() {
        if (StringUtils.isBlank(preMainSchedulerAddr)) {
            preMainSchedulerAddr = preMainSchedulerIp + ":" + preMainSchedulerPort;
        }
        return preMainSchedulerAddr;
    }

    public Date getPreMainSchedulerStartTime() {
        return preMainSchedulerStartTime;
    }

    public void setPreMainSchedulerStartTime(Date preMainSchedulerStartTime) {
        this.preMainSchedulerStartTime = preMainSchedulerStartTime;
    }

    public String getCurMainSchedulerAddr() {
        if (StringUtils.isBlank(curMainSchedulerAddr)) {
            curMainSchedulerAddr = curMainSchedulerIp + ":" + curMainSchedulerPort;
        }
        return curMainSchedulerAddr;
    }

    public Date getCurMainSchedulerStartTime() {
        return curMainSchedulerStartTime;
    }

    public void setCurMainSchedulerStartTime(Date curMainSchedulerStartTime) {
        this.curMainSchedulerStartTime = curMainSchedulerStartTime;
    }

    public String getPreMainSchedulerIp() {
        return preMainSchedulerIp;
    }

    public void setPreMainSchedulerIp(String preMainSchedulerIp) {
        this.preMainSchedulerIp = preMainSchedulerIp;
    }

    public int getPreMainSchedulerPort() {
        return preMainSchedulerPort;
    }

    public void setPreMainSchedulerPort(int preMainSchedulerPort) {
        this.preMainSchedulerPort = preMainSchedulerPort;
    }

    public String getCurMainSchedulerIp() {
        return curMainSchedulerIp;
    }

    public void setCurMainSchedulerIp(String curMainSchedulerIp) {
        this.curMainSchedulerIp = curMainSchedulerIp;
    }

    public int getCurMainSchedulerPort() {
        return curMainSchedulerPort;
    }

    public void setCurMainSchedulerPort(int curMainSchedulerPort) {
        this.curMainSchedulerPort = curMainSchedulerPort;
    }



    /**
     * 设置当前调度信息
     * @param curMainSchedulerIp
     * @param curMainSchedulerPort
     * @param curMainSchedulerStartTime
     */
    public void setCurMainSchedulerInfo(String curMainSchedulerIp, int curMainSchedulerPort, Date curMainSchedulerStartTime) {
        this.setCurMainSchedulerIp(curMainSchedulerIp);
        this.setCurMainSchedulerPort(curMainSchedulerPort);
        this.setCurMainSchedulerStartTime(curMainSchedulerStartTime);
    }
}
